import { ADD_VAL, CLEAR_VAL} from '../type'

export const action_user_changName= (payload) => (dispath) => {
    dispath({
        type: ADD_VAL,
        payload
    })
    
}

export const action_user_clearName = (payload) => (dispath) => {
    // dispath({
    //     type: CLEAR_VAL,
    //     payload
    // })
    console.log('Promise')
    return new Promise((reslove,reject)=> {
        if(payload) {
            reslove(payload)
            dispath({
                type: CLEAR_VAL,
                payload:`${payload},清空成功继续赋值`
            })
        } else {
            reject(payload)
            dispath({
                type: CLEAR_VAL,
                payload: '清空失败'
            })
        }
    })
}

export const action_user_initName = (payload) => (dispath) => {
    console.log('clear_user_name',payload)
}
export const action_base= (payload) => (dispath) => {
    console.log('action --start')
}